<?php

	class Round extends Model{

		private $_RoundId;
		private $_Description;
		private $_TotalMatches;

		function __construct($arrInitialValues = null){
			parent::__construct();

			if (isset($arrInitialValues['round_id']))
				$this->setRoundId($arrInitialValues['round_id']);
			else
				$this->setRoundId(0);

			if (isset($arrInitialValues['description']))
				$this->setDescription($arrInitialValues['description']);
			else
				$this->setDescription('');

			if (isset($arrInitialValues['total_matches']))
				$this->setTotalMatches($arrInitialValues['total_matches']);
			else
				$this->setTotalMatches('');
				
		}
		
		public function setRoundId($value){
			$this->_RoundId = $value;
		}
		
		public function getRoundId(){
			return $this->_RoundId;
		}
		
		public function setDescription($value){
			$this->_Description = $value;
		}
		
		public function getDescription(){
			return $this->_Description;
		}

		public function setTotalMatches($value){
			$this->_TotalMatches = $value;
		}
		
		public function getTotalMatches(){
			return $this->_TotalMatches;
		}
		
		public function getAllRounds(){
			$query = '
				SELECT *
				FROM rounds
				ORDER BY round_id';
			
			$dbHelper = new DBHelper($query);
			return $dbHelper->getResult();
		}
		
		public function getRound(){
			$query = '
				SELECT *
				FROM rounds
				WHERE round_id = ' . $this->getRoundId();
			
			$dbHelper = new DBHelper($query);
			$result = $dbHelper->getResult();
			$this->setDescription($result[0]['description']);
			$this->setTotalMatches($result[0]['total_matches']);
		}
	}
?>
